# views/config_views.py
from PySide6.QtWidgets import QWidget, QVBoxLayout, QPushButton, QLabel
from PySide6.QtCore import Qt

class ConfigPage1(QWidget):
    def __init__(self, event_bus, page_manager, app_container):
        super().__init__()
        self.event_bus = event_bus
        self.page_manager = page_manager
        self.app_container = app_container  # 持有全局容器引用
        self.init_ui()

    def init_ui(self):
        layout = QVBoxLayout(self)
        layout.addWidget(QLabel("配置页面1：用户协议", alignment=Qt.AlignCenter))
        next_btn = QPushButton("同意并继续")
        next_btn.clicked.connect(self.goto_next)
        layout.addWidget(next_btn)

    def goto_next(self):
        """跳转到配置页面2"""
        # from . import ConfigPage2
        self.page_manager.push_page(
            self.app_container.config_stack,
            ConfigPage2(self.event_bus, self.page_manager, self.app_container)
        )



class ConfigPage2(QWidget):
    def __init__(self, event_bus, page_manager, app_container):
        super().__init__()
        self.event_bus = event_bus
        self.page_manager = page_manager
        self.app_container = app_container  # 持有全局容器引用
        self.init_ui()

    def init_ui(self):
        layout = QVBoxLayout(self)
        layout.addWidget(QLabel("配置页面2：隐私协议", alignment=Qt.AlignCenter))
        next_btn = QPushButton("同意并继续")
        next_btn.clicked.connect(self.finish_config)
        layout.addWidget(next_btn)



    def finish_config(self):
        """配置完成，通知全局容器进入功能模块"""
        self.page_manager.clear_stack(self.app_container.config_stack)
        self.app_container.enter_main_function()  # 调用全局容器的方法切换